

#ifndef APP_LIB_STREAMS_IOSTREAM_H_
#define APP_LIB_STREAMS_IOSTREAM_H_

#include <stream.h>
#include "ringbuffer.h"


typedef unsigned int (* IoStream_Output_t)(void *instance, const void *data, unsigned int size);

typedef struct
{
    const struct BaseStreamVMT  *vmt;
    IoStream_Output_t output;
    rbuf_t rxRBuf;
    void *_rxBuf;
    void *userData;
}IoStream_t;

void IoStream_Init(
        IoStream_t *stream,
        void *buf,
        unsigned int bufSize,
        IoStream_Output_t output,
        void *userData);
int IoStream_HardwareInput(IoStream_t *stream, uint8_t b);
void IoStream_ClearRxBuffer(IoStream_t *stream);

#endif /* APP_LIB_STREAMS_IOSTREAM_H_ */
